#include <iostream>
using namespace std;

int main()
{
    int MonthDays[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int year=0;
    int month=0;
    int day=0;
    int n=0;
    cin>>year>>month>>day;
    int i=0;
    for(i=1;i<month;i++)
    {
        n+=MonthDays[i];
    }
    n+=day;
    if(month >2 && ((year%4 ==0 && year%100 != 0) || (year % 400 ==0)))
            {
              n+=1;
            }
            cout<<n<<endl;
   return 0;
}
